﻿using Fuse8.ContentManagementFramework.Domain.Bases;
using Fuse8.ContentManagementFramework.SystemFacade;
using Fuse8.DomainFramework.Common;
using System;
using System.Collections.Generic;

namespace Fuse8.ContentManagementFramework.Domain.Special
{
    public class CmsUserUpdatedEmail : BaseEmail<CmsUser>
    {
        public CmsUserUpdatedEmail(CmsUser user)
        {
            Guard.ArgumentNotNull(user, "user");

            Model = user;

            To = new string[] { user.UserEmail };

            From = CmsConfiguration.SystemSenderEmail;

            Subject = "Your cms account has been updated";

            TemplateUrl = "/admin/assets/templates/UserUpdated.html";
        }

        public override void Prepare()
        {
            ReplacementProperties = new Dictionary<string, string>();

            if (Model != null)
            {
                ReplacementProperties.Add("UserName", Model.UserName);
                ReplacementProperties.Add("UserEmail", Model.UserEmail);
                ReplacementProperties.Add("LoginName", Model.LoginName);
                ReplacementProperties.Add("PlainPassword", Model.PlainPassword);
                ReplacementProperties.Add("DateCreated", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"));
            }
        }
    }
}